#ifndef CACHEH
#define CACHEH

#include <vector>
#include <list>

class Cache {
public:
	Cache(int nPointsIn, int cacheSizeIn):nPoints(nPointsIn),cacheSize(cacheSizeIn), occupancy(0),hits(0),compulsoryMisses(0),capacityMisses(0) {
		directory.reserve(nPointsIn);
		{
			DirectoryEntry tmp;
			directory.assign(nPointsIn,tmp);
		}
	}
	~Cache(){}
	void findData(const int index, int &offset, bool &compute);
	//void search(const int index, int &offset, bool &compute);
	void printCache();
	void printStatistics();
private:
	int nPoints;
	int cacheSize;
	int occupancy;
	int hits;
	int compulsoryMisses;
	int capacityMisses;
	class DirectoryEntry {
	public:
		enum dictionaryStatus{NEVER, EVICTED, INCACHE};
		DirectoryEntry():status(NEVER),location(-1) {}
		int status;
		int location;
		std::list<int>::iterator lruListEntry;
	};
	std::vector<DirectoryEntry> directory;
	std::list<int> lruList; //Least Recently Used List
};

#endif
